<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        function selectAll(){  
	    if ($("#SelectAll").attr("checked")) {  
	        $(":checkbox").attr("checked", true);  
	    } else {  
	        $(":checkbox").attr("checked", false);  
	    }  
	}  
	
	//子复选框的事件  
	function setSelectAll(){  
	    //当没有选中某个子复选框时，SelectAll取消选中  
	    if (!$("#subcheck").checked) {  
	        $("#SelectAll").attr("checked", false);  
	    }  
	    var chsub = $("input[type='checkbox'][id='subcheck']").length; //获取subcheck的个数  
	    var checkedsub = $("input[type='checkbox'][id='subcheck']:checked").length; //获取选中的subcheck的个数  
	    
	    if (checkedsub == chsub) {  
	        $("#SelectAll").attr("checked", true);  
	    } 
    }
        
        
        //指派
	function assign(){
		var chk_value =[];    
		$("input[type='checkbox'][id='subcheck']:checked").each(function(){    
		 chk_value.push($(this).val());    
		});  	
		var userid = $("#user1Name").val();
		if (userid=="")
		{
			alert("请选择用户！");
			return;
		}
		if (chk_value.length >0){
			$.get("${ctx}/cms/taskOperation/assign2?ids=" + JSON.stringify(chk_value)+"&userid="+$("#user1Name").val(), function(data){
					alert(JSON.stringify(data)); 
					$("#searchForm").submit();
			});
		}else{
			alert("请选择数据！");
		}
	}
    
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/cms/taskChange/">信息列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="taskOperation" action="${ctx}/cms/taskChange/change" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<%-- <li><label>关键字段：</label>
				<form:input path="keyfield" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li> --%>
			<li><label>产品字段：</label>
				<form:input path="productid" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li><label>产品名称：</label>
				<form:input path="productname" htmlEscape="false" maxlength="128" class="input-medium"/>
			</li>
			<li><label>工段任务：</label>
				<form:input path="opdesc" htmlEscape="false" maxlength="8" class="input-medium"/>
			</li>
			<li><label>子任务：</label>
				<form:input path="dptask" htmlEscape="false" maxlength="8" class="input-medium"/>
			</li>
			
			<li><label style="display:inline">计划开工日期：</label>
				<input name="pdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${taskOperation.pdate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
			<li><a class="btn btn-primary" href="javascript:assign();" onclick="return confirmx('确认指派吗？', this.href)">指派执行账户</a> &nbsp;
				<sys:treeselect2 id="user1" name="user.loginName" value="${testData.user.loginName}" labelName="user.loginName" labelValue="${testData.user.loginName}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
			</li>
			
		</ul>
		
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" style="width: 1600px" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th>
				<p><input type="checkbox" id="SelectAll"
					onclick="selectAll()" /></p>
				</th>
				<th>关键字段</th>
				<th>产品id</th>
				<th>产品名称</th>
				<th>工序</th>
				<th>子任务</th>
				<th>部门</th>
				<th>任务计划日期</th>
				<th>产值</th>
				<th>任务类型</th>
				<th>任务是否完工</th>
				<th>是否标志工序</th>
				<th>是否工段完成</th>
				<th>是否检验任务</th>
				<th>是否合格</th>
				<th>是否开工</th>
				<th>用户id</th>
				<%-- <shiro:hasPermission name="cms:taskOperation:edit"><th>操作</th></shiro:hasPermission> --%>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="taskOperation">
			<tr>
				<td><input type="checkbox" id="subcheck"
						value="${taskOperation.id}" onclick="setSelectAll()"></input>
					</td>	
				<td>${taskOperation.keyfield}</td>
				<td>${taskOperation.productid}</td>
				<td>${taskOperation.productname}</td>
				<td>${taskOperation.opdesc}</td>
				<td>${taskOperation.dptask}</td>
				<td>${taskOperation.dept}</td>
				<td><fmt:formatDate value="${taskOperation.pdate}" pattern="yyyy-MM-dd"/></td>
				<td>${taskOperation.a}</td>
				<td>${taskOperation.tasktype}</td>
				<td>${taskOperation.istaskcomplete}</td>
				<td>${taskOperation.istagprocess}</td>
				<td>${taskOperation.ispartcomplete}</td>
				<td>${taskOperation.isqctask}</td>
				<td>${taskOperation.isok}</td>
				<td>${taskOperation.isstart}</td>
				<td>${taskOperation.userid}</td>
				<%-- <shiro:hasPermission name="cms:taskOperation:edit"><td>
    				<a href="${ctx}/cms/taskOperation/form?id=${taskOperation.id}">修改</a>
					<a href="${ctx}/cms/taskOperation/delete?id=${taskOperation.id}" onclick="return confirmx('确认要删除该信息吗？', this.href)">删除</a>
				</td></shiro:hasPermission> --%>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>